{include file="header" /}
<div class="fly-msg" style="margin-bottom: 20px;">支付记录 </div>
<div class="layui-row layui-col-space20">
    <div class="layui-col-md12">
        <div class="fly-home fly-panel" style="text-align: left">
            <form class="layui-form layui-form-pane" action="javascript:;" method="post">
            <div class="layui-form-item">

                <div class="layui-inline">
                    <label class="layui-form-label">订单时间:</label>
                    <div class="layui-input-inline" style="width: 100px;">
                        <input type="text"  name="start_addtime" id="start_addtime" placeholder="" autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-form-mid">-</div>
                    <div class="layui-input-inline" style="width: 100px;">
                        <input type="text" name="end_addtime" id="end_addtime" placeholder="" autocomplete="off" class="layui-input">
                    </div>
                </div>

                <div class="layui-inline">

                    <div class="layui-input-inline" style="width: 100px;">
                        <select name="status" class="layui-input layui-unselect">
                            <option value="" selected="">全部状态</option>
                            <option value="unpay">交易未支付</option>
                            <option value="succ">交易成功</option>
                            <option value="progress">交易处理中</option>
                            <option value="cancel">交易取消</option>
                        </select>

                    </div>
                </div>  <div class="layui-inline">

                    <div class="layui-input-inline" style="width: 100px;">
                        <input class="layui-btn" lay-submit lay-filter="formDemo" type="button" value="搜索" id="search">
                    </div>
                </div>

            </div>
            </form>
            <table class="layui-hide" id="test"></table>

        </div>

    </div>

</div>
{include file="footer" /}
<script type="text/html" id="statusTpl">
    <span class="pay_{{d.status}}">
    {{#  if(d.status == 'unpay'){ }}
    交易未支付
        {{#  } else if(d.status == 'succ') { }}
        交易成功
         {{#  } else if(d.status == 'failed') { }}
        交易失败
        {{#  } else if(d.status == 'failed') { }}
        交易错误
         {{#  } else if(d.status == 'progress') { }}
        交易处理中
        {{#  } else if(d.status == 'timeout') { }}
        交易超时
        {{#  } else if(d.status == 'cancel') { }}
        交易取消
         {{#  } else if(d.status == 'waitting') { }}
        等待付款
    {{#  } else { }}
    未知支付状态
    {{#  } }}
</span>
</script>
<script type="text/html" id="czTpl">
    <span class="pay_{{d.status}}">
    {{#  if(d.status == 'unpay'){ }}
         <form class="layui-form" action="{:url('payment/index/index')}" method="post">
              <input type="hidden" name="order_sn" value="{{d.trade_sn}}">
                        <button class="layui-btn layui-btn-danger layui-btn-xs" lay-submit lay-filter="formPayment">立即付款</button>

         </form>
        {{#  } else if(d.status == 'succ') { }}
        <span class="layui-btn layui-btn-xs">交易完成</span>
         {{#  } else if(d.status == 'failed') { }}
        交易失败
        {{#  } else if(d.status == 'failed') { }}
        交易错误
         {{#  } else if(d.status == 'progress') { }}
        交易处理中
        {{#  } else if(d.status == 'timeout') { }}
        交易超时
        {{#  } else if(d.status == 'cancel') { }}
        交易取消
         {{#  } else if(d.status == 'waitting') { }}
        等待付款
    {{#  } else { }}
    未知支付状态
    {{#  } }}
</span>
</script>
<script>
    layui.use(['form', 'layer', 'jquery','table','laydate'], function(){
        var table = layui.table
            ,form = layui.form,
            layer = layui.layer,
            laydate = layui.laydate,
            $ = layui.jquery;
        laydate.render({
            elem: '#start_addtime'
            ,value: '{:date("Y-m-d",time())}'
            ,showBottom: false
        });
        laydate.render({
            elem: '#end_addtime'
            ,value: '{:date("Y-m-d",strtotime(" + 1day"))}'
            ,showBottom: false
        });
        form.on('submit(formPayment)', function(data){
            console.log(data.field);


        });
        //监听提交
        form.on('submit(formDemo)', function(data){
            var datas= data.field;

            /*       if(datas.type==''){
                       layer.msg('消费类型不能为空')
                       return false;
                   }*/

            table.render({
                elem: '#test'
                ,url:'{:url("OnlineRecharge/payment_log")}'
                ,method:'post'
                ,where:datas
                ,cols: [[
                    {field:'id',  title: 'ID', sort: true}
                    ,{field:'trade_sn', title: '支付单号', sort: true}
                    ,{field:'paytime',  title: '支付时间', sort: true}
                    ,{field:'payment', title: '支付方式', sort: true}
                    ,{field:'money',  title: '存入金额', sort: true}
                    ,{field:'status', title: '支付状态', sort: true, templet: '#statusTpl'}
                    ,{field:'addtime', title: '创建时间', sort: true}
                    ,{ title: '操作', fixed: 'right', templet: '#czTpl'}

                ]]
                ,page: true
            });

            return false;
        });
        table.render({
            elem: '#test'
            ,url:'{:url("OnlineRecharge/payment_log")}'
            ,method:'post'
            ,cols: [[
                {field:'id',  title: 'ID', sort: true}
                ,{field:'trade_sn', title: '支付单号', sort: true}
                ,{field:'paytime',  title: '支付时间', sort: true}
                ,{field:'payment', title: '支付方式', sort: true}
                ,{field:'money',  title: '存入金额', sort: true}
                ,{field:'status', title: '支付状态', sort: true, templet: '#statusTpl'}
                ,{field:'addtime', title: '创建时间', sort: true}
                ,{ title: '操作', fixed: 'right', templet: '#czTpl'}

            ]]
            ,page: true
        });
    });
</script>
